<template>
  <div class="box">
    <myhead></myhead>
    <div class="hearder">
      <img src="../../assets/images/chocolateimg/t_banner_gifts.jpg" alt="" />
    </div>
    <div class="title">
      <router-link to="home">首页</router-link>>
      <router-link to="chocolates">品牌巧克力</router-link>>
      <router-link to="chocolates">巧克力</router-link>
    </div>
    <div class="navbar">
      <ul>
        <li @click="currindex = 0">
          <router-link to="chocolates" :class="{ active: currindex == 0 }">
            <a href=""></a>
            <br />
            全部
          </router-link>
        </li>
        <li @click="currindex = 1">
          <router-link to="chocolates" :class="{ active: currindex == 1 }">
            <a href=""></a>
            <br />
            音乐盒
          </router-link>
        </li>
        <li @click="currindex = 2">
          <router-link to="chocolates" :class="{ active: currindex == 2 }">
            <a href=""></a>
            <br />
            金箔花
          </router-link>
        </li>
        <li @click="currindex = 3">
          <router-link to="chocolates" :class="{ active: currindex == 3 }">
            <a href=""></a>
            <br />
            3D水晶内雕
          </router-link>
        </li>
        <li @click="currindex = 4">
          <router-link to="chocolates" :class="{ active: currindex == 4 }">
            <a href=""></a>
            <br />
            首饰/美妆
          </router-link>
        </li>
        <li @click="currindex = 5">
          <router-link to="chocolates" :class="{ active: currindex == 5 }">
            <a href=""></a>
            <br />
            巧克力
          </router-link>
        </li>
        <li @click="currindex = 6">
          <router-link to="chocolates" :class="{ active: currindex == 6 }">
            <a href=""></a>
            <br />
            公仔/睡枕
          </router-link>
        </li>
        <li @click="currindex = 7">
          <router-link to="chocolates" :class="{ active: currindex == 7 }">
            <a href=""></a>
            <br />
            其他/摆件
          </router-link>
        </li>
      </ul>
    </div>
    <div class="filter">
      <div class="pin">
        品牌:
        <a
          href="#"
          @click="currindex2 = 0"
          :class="{ active2: currindex2 == 0 }"
          >进口Felchlin巧克力</a
        ><a
          href="#"
          @click="currindex2 = 1"
          :class="{ active2: currindex2 == 1 }"
          >巧蔻巧克力</a
        >
      </div>
      <div class="pai">
        排序:
        <a
          href="#"
          @click="currindex3 = 0"
          :class="{ active3: currindex3 == 0 }"
          >综合</a
        ><a
          href="#"
          @click="currindex3 = 1"
          :class="{ active3: currindex3 == 1 }"
          >销量</a
        ><a
          href="#"
          @click="currindex3 = 2"
          :class="{ active3: currindex3 == 2 }"
          >最新</a
        ><a
          href="#"
          @click="currindex3 = 3"
          :class="{ active3: currindex3 == 3 }"
          >价格 </a
        ><span class="iconfont icon-shangxiajiantou"></span>
        <input type="text" placeholder="￥" v-model="msg" />{{ msg }}—
        <input type="text" placeholder="￥" v-model="msg2" />{{ msg2 }}
        <button class="qu" @click="sai()">确定</button>
        <button class="qin">清空</button>
      </div>
    </div>
    <div class="item">
      <ul>
        <li v-for="(item, index) in arr" :key="index">
          <router-link to="/detail">
            <div class="img">
              <img
                v-lazy="require('../../assets/images/chocolateimg/' + item.img)"
                alt=""
              />
            </div>

            <div class="itemtitle">
              <p class="title">
                <span v-if="item.title" style="padding: 2px 8px">{{
                  item.title
                }}</span>
              </p>
              <p class="content">{{ item.content }}</p>
              <p class="price">￥{{ item.price }}</p>
            </div>
            <p class="dec">{{ item.dec }}</p>
          </router-link>
        </li>
      </ul>
    </div>
    <!-- <div class="kefu">
      <div class="left">
        <span></span>
      </div>
      <div class="right">咨询客服</div>
    </div> -->
    <mysild></mysild>
    <myfoot></myfoot>
  </div>
</template>

<script>
import "./font_2361634_1zc6rbhfslx/iconfont.css";
import myhead from "../../components/Header/header.vue";
import myfoot from "../../components/Footer/footer.vue";
import mysild from "../../components/Side/side.vue";

export default {
  components: { myhead, myfoot, mysild },
  data() {
    return {
      currindex: 5,
      currindex2: "",
      currindex3: 0,
      arr: [],
      allArr: [],
      msg: "",
      msg2: "",
    };
  },
  mounted() {
    this.$axios.get("../../static/data/chocolate.json").then((res) => {
      this.allArr = res.data.data;
      this.arr = this.allArr;
    });
  },
  methods: {
    sai() {
      var arr2 = [];3
      console.log(this.msg, this.msg2);
      this.allArr.filter((item) => {
        if (
          parseInt(item.price) >= parseInt(this.msg) &&
          parseInt(item.price) <= parseInt(this.msg2)
        ) {
          arr2.push(item);
        }
      });
      this.arr = arr2;
      console.log(arr2);
    },
  },
};
</script>

<style scoped lang='less'>
.hearder {
  width: 1200px;
  height: 70px;
  margin: 0 auto;
  .hearder img {
    width: 100%;
    height: 100%;
  }
}
.title {
  text-align: left;
  width: 1200px;
  margin: 0 auto;
  margin-top: 15px;
  color: gray;
  a {
    color: gray;
  }
  a:hover {
    color: orange;
  }
}
.navbar {
  width: 1200px;
  margin: 20px auto;
  ul {
    width: 1300px;
    height: 77px;
    display: flex;
    justify-content: space-between;
    margin-left: -50px;
    font-size: 16px;
    li {
      width: 12.5%;
      text-align: center;
      list-style: none;
      a {
        color: gray;
        text-decoration: none;
      }
    }
    li:nth-of-type(1) a > a {
      display: inline-block;
      width: 50px;
      height: 50px;
      background: url(../../assets/images/chocolateimg/gifts-sprite.png) -2px 2px
        no-repeat;
    }
    li:nth-of-type(2) a > a {
      display: inline-block;
      width: 50px;
      height: 50px;
      background: url(../../assets/images/chocolateimg/gifts-sprite.png) -59px -4px
        no-repeat;
    }
    li:nth-of-type(3) a > a {
      display: inline-block;
      width: 50px;
      height: 50px;
      background: url(../../assets/images/chocolateimg/gifts-sprite.png) -113px -4px
        no-repeat;
    }
    li:nth-of-type(4) a > a {
      display: inline-block;
      width: 50px;
      height: 50px;
      background: url(../../assets/images/chocolateimg/gifts-sprite.png) -165px -4px
        no-repeat;
    }
    li:nth-of-type(5) a > a {
      display: inline-block;
      width: 50px;
      height: 50px;
      background: url(../../assets/images/chocolateimg/gifts-sprite.png) -227px -4px
        no-repeat;
    }
    li:nth-of-type(6) a > a {
      display: inline-block;
      width: 50px;
      height: 50px;
      background: url(../../assets/images/chocolateimg/gifts-sprite.png) -282px -4px
        no-repeat;
    }
    li:nth-of-type(7) a > a {
      display: inline-block;
      width: 50px;
      height: 50px;
      background: url(../../assets/images/chocolateimg/gifts-sprite.png) -338px -4px
        no-repeat;
    }
    li:nth-of-type(8) a > a {
      display: inline-block;
      width: 50px;
      height: 50px;
      background: url(../../assets/images/chocolateimg/gifts-sprite.png) -394px -4px
        no-repeat;
    }
    li a:hover {
      color: orange;
    }
    .active {
      color: orange;
    }
  }
}
.filter {
  width: 1200px;
  margin: 0 auto;

  .pin {
    text-indent: 20px;
    padding: 25px 0;
    background-color: rgb(245, 245, 245);
    color: gray;
    a {
      text-decoration: none;
      margin-left: 35px;
      color: gray;
    }
    a:hover {
      color: orange;
    }
    .active2 {
      color: orange;
    }
  }
  .pai {
    text-indent: 20px;
    padding: 25px 0;
    background-color: rgb(245, 245, 245);
    color: gray;
    margin-top: 1px;
    a {
      margin-left: 35px;
      color: gray;
      text-decoration: none;
    }
    span {
      font-size: 14px;
    }
    a:hover {
      color: orange;
    }
    .active3 {
      color: orange;
    }
    input {
      width: 100px;
      margin: 0px 20px;
      border: 1px solid #bcbcbc;
      outline-color: #ff6a00;
      box-shadow: 0 0 0 999px #fff inset;
      border-radius: 2px;
    }
    button {
      border: none;
    }
    .qu {
      background-color: rgb(255, 182, 142);
      padding: 2px 15px;
      color: black;
      outline: none;
    }
    .qin {
      background-color: rgb(230, 230, 230);
      padding: 2px 15px;
      color: black;
      outline: none;
    }
  }
}
.item {
  width: 1225px;
  margin: 0 auto;
  ul {
    margin-top: 48px;
    li {
      a {
        color: black;
        text-decoration: none;
      }
      width: 282px;
      height: 434px;
      float: left;
      list-style: none;
      margin-right: 24px;
      margin-bottom: 80px;
      .img {
        width: 282px;
        height: 307px;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .itemtitle {
        padding: 5px 0;
        border-bottom: 1px solid gainsboro;
        .title {
          width: 100%;
          height: 30px;
          font-size: 12px;
          span {
            display: inline-block;
            background-color: orangered;
            color: white;
          }
        }
        .content {
          white-space: nowrap;
          text-overflow: ellipsis;
          overflow: hidden;
        }
        .price {
          color: #ff6a00;
        }
      }
      .dec {
        color: gray;
        font-size: 11px;
        margin-top: 5px;
      }
    }
    .img:hover {
      transform: scale(1.04);
      transition: all linear 0.5s;
    }
  }
}
.kefu {
  width: 180px;
  height: 40px;
  background-color: orangered;
  position: fixed;
  right: 40px;
  bottom: 0;
  .left {
    float: left;
    height: 100%;
    width: 35%;
    border-right: 1px solid #bcbcbc;
    span {
      display: inline-block;
      width: 50px;
      height: 30px;
      margin: 5px auto;
      background: url(../../assets/images/chocolateimg/icon-mq-round@2x.png)
        14px 0px no-repeat;
      background-size: 72px 651px;
    }
  }
  .right {
    float: left;
    width: 60%;
    height: 100%;
    line-height: 40px;
    text-align: center;
    font-size: 16px;
    color: white;
  }
}
</style>